<html>
	<head>
		<title>{$_TR.file_picker_title}</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<script type="text/javascript" src="{$smarty.const.THEME_RELATIVE}js/jquery-1.4.4.min.js"></script>
		<script type="text/javascript" src="{$smarty.const.THEME_RELATIVE}upload/jquery.uploadify.js"></script>
		<link rel="stylesheet" type="text/css" href="/js/lytebox3.25/lytebox.css">
        <script type="text/javascript" src="/js/lytebox3.25/lytebox.js"></script>
		<script type="text/javascript" src="{$smarty.const.THEME_RELATIVE}modules/filemanagementmodule/jquery.floatdialog.js"></script>
		 <link rel="stylesheet" href="{$smarty.const.THEME_RELATIVE}upload/uploadify.css" type="text/css" />
	 <link rel="stylesheet" href="{$smarty.const.THEME_RELATIVE}modules/filemanagementmodule/style.css" type="text/css" />
		 

		<style type="text/css">
			{literal}
			html{
				background-image: none;
			}
			body {
				margin: 0px;
				padding: 0px;
				background-image: none;
				background-color: #Cedbc6;
				color: black;
			}
			
			table {
			 color: black;
	  }
	  
	  a {
		color: black;
	  }
	  a:visited {
		color: #660000;
	  }
	  
	  .moduletable {
		  width: 210px;
	  }
	  
	  li{
		background-image: url({/literal}{$smarty.const.THEME_RELATIVE}modules/filemanagementmodule/bullet.png{literal});
		background-repeat: no-repeat;
		padding-left: 25px;
		line-height: 20px;
		padding-top: 5px;
	  }

			div.imagecollection_sidebar {
				background-color: white;
				border-right: 2px solid black;
				border-bottom: 2px solid black;
				border-top: 2px solid black;
				border-left: 2px solid black;
				font-size: 11pt;
				position: absolute;
				left: 5px;
				top: 5px;
				padding: 2px;
				width: 210px;
			}

			div.imagecollection_sidebar ul {
				margin: 0px;
				padding: 0px;
			}
			div.imagecollection_sidebar ul li {
				list-style: none;
			}

			div.imagecollection_sidebar a {
				color: black;
				text-decoration: none;
				font-weight: bold;
				font-size: 13px;
			}

			div.imagecollection_sidebar a:hover {
				color: black;
				text-decoration: underline;
				font-weight: bold;
			}

			div.imagecollection_previews {
				padding: 1em;
				margin-bottom: 30px;
				margin-left: 220px;
			}

			div.scroller {
				width: 100%;
		height: 100%;
				overflow: none;
			}

			div.imagecollection_previews table tr td {
				text-align: center;
				border: 1px solid #666;
				font-size: 10px;
				padding: 5px;
			}

			div.imagecollection_previews table tr td a {
				text-decoration: none;
				color: darkblue;
				font-weight: bold;
			}

			div.imagecollection_upload {
				background-color: #999;
				border-top: 2px solid black;
				border-left: 2px solid black;
				padding: .2em;
				text-align: right;
				font-size: 11px;
				position: fixed;
				bottom: 50;
				right: 20px;
				height: 100px;
			}

			div.imagecollection_previews table tr td img {
				border: 1px solid white;
			}

			div.imagecollection_previews table tr td#highlight img {
				background-color: #CCC;
				border: 6px solid black;
			}

			div.imagecollection_previews table tr td:hover img {
				border: 1px solid black;
			}
		{/literal}
		</style>
		{literal}<script language="Javascript">
		    function ajax_string_dim(data){
                temp=data.substring(0,1);
                if ((temp =="\r") || (temp == "\n"))
                    data=data.substring(1);
                temp=data.substring(0,1);
                if ((temp =="\r") || (temp == "\n"))
                    data=data.substring(1);
                return data;
            }  
$(document).ready(function() {
    $(function(){
        $.superbox();
    });

	// for file upload
	$("#fileupload").fileUpload({
		{/literal}
		'uploader': '{$smarty.const.THEME_RELATIVE}upload/uploader.swf',
		'cancelImg': '{$smarty.const.THEME_RELATIVE}upload/cancel.png',
		{literal}
		'script': 'upload_standalone.php',
		'multi': true,
		'buttonText': 'Browse',
		'fileExt'     : '*.jpg;*.gif;*.png;*.bmp;*.jpeg;*.flv;*.mp3;*.doc;*.docx',
		'fileDesc'    : 'Image, Sound, Video Files',
		'scriptData': {
			'collection_id':'{/literal}{$id}', 
			'save_session': "{$session_id}"{literal}
			
		},
		'displayData': 'speed',
		onComplete: function (evt, queueID, fileObj, response, data) {
		  //alert(response);
          response=ajax_string_dim(response);
		  var temp = response.indexOf(' ');
		  var temp_text = response.substr(temp+1);
		  temp = response.substr(0,temp);
		  if (temp== '-1')
			alert(temp_text);
			return true;
		},
		onAllComplete: function (evt, data) {
			window.location.href=window.location.href;
			//alert(data);
		}

	});
});

</script>{/literal}
		
		<script type="text/javascript" src="../../../exponent.js.php"></script>
		<script type="text/javascript">
		{literal}
			// fckedior unfortunately does not ship with our efm_pickedFile() :)
			function _RetFile(id, path){
				if (window.opener!== null)
				{
					window.opener.efm_pickedFile(id, path);
					window.close();
				}
				else
				{
					parent.efm_pickedFile(id, path);
				}
			}
			
			function FCKeditor_pickedFile(id, pickedFile) {
				window.opener.SetUrl(eXp.PATH_RELATIVE + pickedFile);
			}
			if (typeof window.opener.FCK == "object" && typeof window.opener.oEditor == "object") {
				//attach this to the window that opened the filemanager(=FCKeditor`s image insert)
				window.opener.efm_pickedFile = FCKeditor_pickedFile;
			}
			function openWindow(filename,width,height) {
				if (width != 0) {
					width = width+40;
					if (width > 600) width = 600;
				} else {
					width = 400;
				}

				if (height != 0) {
					height = height+40;
					if (height > 400) height = 400;
				} else {
					height = 400;
				}

				//window.open(filename,'image'+Math.random(),'status=no,status=no,width='+width+',height='+height);
				window.open(filename,'image'+Math.random(),'status=yes,status=yes,width='+width+',height='+height);
				return false;
			}
		{/literal}
		</script>
	</head>
	<body>
		<!-- SideBar -->
		<div class="imagecollection_sidebar">
			<div class="moduletable" >
				<h3><span>&nbsp;
			<b><font style="font-size: 20px;" >{$_TR.cat}</font></b></span></h3>
			<ul>
				<li><a href="?id=0"><i>{$_TR.uncategorized}</i></a></li>
				{foreach from=$collections item=collect}
				<li>
		  &nbsp;<a href="?id={$collect->id}">{$collect->name}</a>
		</li>
				{/foreach}
			</ul>
			</div>
			<br>
				<div align=center>
				{if !$normalUserOnly}
		  <a id="new_collection" href="javascript: void(0);" onclick="javascript:collection_dialog(-1,'','');" ><font style="font-size: 18px;"><img style="margin-top: 5px;" src="{$smarty.const.URL_FULL}modules/filemanagermodule/images/category.png">&nbsp;<span id="new_collection-dialog_URL">{$_TR.add_new_collection}</span></font></a>
		  {/if}
		</div>
	  <div id="new_collection_dialog" >
		<div style="font-size: 14px; font-family: verdana;">
		   <b><span id="new_collection-dialog_header" style="padding-bottom: 15px; font-weight: bold;">{$_TR.add_new_collection}</span></b>
		</div>
				<form id="new_collection_form" action='{$smarty.const.URL_FULL}index.php' method=post>
				  <table border=0>
					<tr>
					  <td>
				<b>{$_TR.name}&nbsp;</b>				        
					  </td>
					  <td>
						<input type=text id="name" name='name' size=20> 
					  </td>
			</tr>
			<tr>
					  <td>
				<b>{$_TR.des}&nbsp;</b>        
					  </td>
					  <td>
						<input type=hidden name="id" id="id" value="-1">
						<input type=hidden name=module value='filemanagermodule'>
							<input type=text id="des" name='description' value='' size=20>
				<input type=hidden name='action' value='save_collection' id="collection_dialog_action"> 
					  </td>
			</tr>
				  </table>
				  <div align=center style="padding-top: 10px;"><input type=submit value='OK'></div>
				</form>
			 </div>
			 <script>{literal}
                jQuery("#new_collection_form").submit(function(){
                    if (jQuery("#name").val() == "")
                    {
                        alert("Please enter name");
                        jQuery("#name").focus();
                        return false;
                    }
                    return true;
                });
		$("#new_collection").floatdialog("new_collection_dialog", {event: 'click', move:'down', closeClass: '.myclosebutton' });
	   </script>{/literal}
			
			<div class="moduletable" style="padding-top: 20px;">
				<h3><span style="padding-bottom: 15px; font-weight: bold;">{$_TR.upload}</span></h3>
				  <div align=center>
					<div id="fileupload">
						<input type="file" class="filebtn" name="fileupload" enctype="multipart/form-data" size="35" value="1" onchange="updateSubmitState()">
You have a problem with your javascript or You have not enabled Flash Control</div>
		  </div>
					<div align=center>
					<a href="javascript:$('#fileupload').fileUploadStart()">{$_TR.upload_now}</a></div>
					</div>
			</div>
		</div>
		<!-- End of SideBar -->
		{if !$normalUserOnly}
		{literal}
		<script language="javascript">
		  function collection_dialog(id,name,des)
		  {
			var control = document.getElementById('id');
			control.value=id;
			control = document.getElementById('name');
			control.value=name;
			control = document.getElementById('des');
			control.value=des;
			if (id == -1) // create new
			{
			  control = document.getElementById('new_collection-dialog_header');
			  control.innerHTML='{/literal}{$_TR.add_new_collection}{literal}';
			}
		else
		{
		  control = document.getElementById('new_collection-dialog_header');
			  control.innerHTML='{/literal}{$_TR.edit_collection}{literal}';
		} 
	  }
		</script>{/literal}
		{/if}
		<div class="imagecollection_previews">
			<div style="font-size: larger;"><b>{$collection->name}</b>&nbsp;({$item_count} {plural singular=file plural=files count=$item_count})
		 <a id="edit_collection" href="javascript: void(0);" onclick="javascript: collection_dialog({$collection->id},'{$collection->name}','{$collection->description}');"><img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}edit.png" title="{$_TR.edit_collection}" alt="{$_TR.edit_collection}" /></a>
				 <a href="{link action=delete_collection module=filemanagermodule id=$collection->id}"><img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.delete_collection}" alt="{$_TR.delete_collection}" onclick="return confirm('{$_TR.delete_link_confirm}');" /></a>
	  </div>
	  {literal}
	  <script>
		$("#edit_collection").floatdialog("new_collection_dialog", {event: 'click', move:'down', closeClass: '.myclosebutton' });
	  </script>{/literal}
			<div style="padding-left: 2em; margin-bottom: 1em; border-bottom: 2px solid black;">{$collection->description}</div>
			<div >
				<table  >
				<tr>
				<td style="border: 0;">
				<form action="" method='post' name="change_image_count">
					{$_TR.page} <select name='page' onchange="document.forms['change_image_count'].submit();">
						{foreach from=$pages item=page_item}
							<option value={$page_item} {if $page_item == $page} selected {/if}>{$page_item}</option>
						{/foreach}
					</select>
				</td>
				<td style="border: 0;">
					<input type=hidden name='id' value={$id}>
					{$_TR.imager_per_line} <select name="image_per_line" onchange="document.forms['change_image_count'].submit();">
						<option value=3 {if $image_per_line == 3}selected{/if}>3</option>
						<option value=4 {if $image_per_line == 4}selected{/if}>4</option>
						<option value=5 {if $image_per_line == 5}selected{/if}>5</option>
						<option value=6 {if $image_per_line == 6}selected{/if}>6</option>
						<option value=7 {if $image_per_line == 7}selected{/if}>7</option>
						<option value=8 {if $image_per_line == 8}selected{/if}>8</option>
						<option value=9 {if $image_per_line == 9}selected{/if}>9</option>
						<option value=10 {if $image_per_line == 10}selected{/if}>10</option>
					</select>
				</form></td>
				<td style="border: 0;">
					<div align=right style="font-size: 13px; font-weight: bold;">
						{$_TR.size}{$folder_size}
					</div>
				</td>
				</tr>
				</table>
			</div>
			<div class="scroller">
			<table cellspacing=10 >
				<tr>
					{foreach name=i from=$files item=file}
					{if ($smarty.foreach.i.iteration - 1) mod $image_per_line == 0}
						</tr>
						<tr>
					{/if}
					<td style="width: 150px;" height="120" valign="top" align="center"{if $highlight_file == $file->id} id="highlight"{/if}>
						{if $file->is_image}
						<a href="{$smarty.const.PATH_RELATIVE}{$file->directory}/{$file->filename}" onclick="return openWindow('{$smarty.const.PATH_RELATIVE}{$file->directory}/{$file->filename}',{$file->image_width},{$file->image_height});" target="_blank">
							{$file->temp_filename}
						</a>
						<br />
						<a href="#" onclick="_RetFile({$file->id},'{$file->directory}/{$file->filename}'); return false;">
							<img id="#image" src="{$smarty.const.PATH_RELATIVE}phpThumb.php?src={$file->directory}/{$file->filename}&w=100&h=100" title="{if $file->filename != ''} {$file->filename}{else}{$file->name}{/if}" alt="" border="0"/>
						</a>
						<br />
						<a href="{$smarty.const.PATH_RELATIVE}{$file->directory}/{$file->filename}" rel="superbox[image]" title="{if $file->filename != ''} {$file->filename}{else}{$file->name}{/if}">
						
							{$_TR.show_full}
						</a>
						<br />
						{else}
						{getfileicon id=$file->id}
						<br />
							{if $file->name == ''}
							{$file->filename}
							{else}
								{$file->name}
							{/if}
							<br />
							<a href="#" onclick="_RetFile({$file->id},'{$file->directory}/{$file->filename}'); return false;">Use</a>
						{/if}
						<a href="{link action=delete id=$file->id module=filemanagermodule cat_id=$collection->id}" onclick="return confirm('{$_TR.delete_confirm}');"><img class="mngmnt_icon" style="border:none;" src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.delete_desc}" alt="{$_TR.delete_desc}" /></a>
					</td>
					{foreachelse}
					<td><i>{$_TR.no_files}</i></td>
					{/foreach}
				</tr>
			</table>
			</div>
		</div>
	</body>
</html>
